<template>
  <div class="follow body">
    <!--页眉-->
    <div class="页眉"></div>
    <!--分栏-->
    <el-row :gutter="16" type="flex" justify="center">
      <!--菜单栏-->
      <el-col :span="4">
        <div class="文本框" style="height: 900px;">
          <el-menu  router>
            <el-menu-item index="/CreationCenter" >
              <div class="文本">
                <i class="el-icon-menu"></i>
                首页
              </div>
            </el-menu-item>
            <el-submenu index="001">
              <template slot="title">
                <div class="文本">
                  <i class="el-icon-edit-outline"></i>
                  创作
                </div>
              </template>
              <el-menu-item index="/CreationCenter/SendArticle">发布文章</el-menu-item>
              <el-menu-item index="/CreationCenter/SendVideo">发布视频</el-menu-item>
              <el-menu-item index="/CreationCenter/SendReport">发布研报</el-menu-item>
              <el-menu-item index="/CreationCenter/SendTinyArticle">发布富微条</el-menu-item>
            </el-submenu>
            <el-menu-item index="/CreationCenter/ManageArticle">
              <div class="文本">
                <i class="el-icon-reading"></i>
                作品管理
              </div>
            </el-menu-item>
            <el-submenu index="002">
              <template slot="title">
                <div class="文本">
                  <i class="el-icon-view"></i>
                  互动管理
                </div>
              </template>
              <el-menu-item index="/CreationCenter/ManageFollow">关注管理</el-menu-item>
              <el-menu-item index="/CreationCenter/ManageComment">评论管理</el-menu-item>
              <el-menu-item index="/CreationCenter/ManagePM">私信管理</el-menu-item>
            </el-submenu>
            <el-submenu index="003">
              <template slot="title">
                <div class="文本">
                  <i class="el-icon-document"></i>
                  数据分析
                </div>
              </template>
              <el-menu-item index="/CreationCenter/DataArticle">作品数据</el-menu-item>
              <el-menu-item index="/CreationCenter/DataFans">粉丝数据</el-menu-item>
              <el-menu-item index="/CreationCenter/DataProfit">收益数据</el-menu-item>
            </el-submenu>
            <el-menu-item index="/CreationCenter/Option">
              <div class="文本">
                <i class="el-icon-setting"></i>
                设置
              </div>
            </el-menu-item>
          </el-menu>
        </div>
      </el-col>
      <!--正文栏-->
      <el-col :span="14">
        <div class="grid-content">
          <!--路由-->
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/CreationCenter' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>粉丝数据</el-breadcrumb-item>
          </el-breadcrumb>
          <br/>
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <!--概况-->
            <el-tab-pane>
              <span slot="label" style="font-size: 18px">概况</span>
              <!--基本信息-->
              <el-row :gutter="16" type="flex" justify="center">
                <el-col  :span="5">
                  <div class="文本框">
                    <div class="文本 居中">
                      昨日粉丝变化数
                    </div>
                    <div class="文本-巨型 居中">
                      +1
                    </div>
                    <div class="文本 居中">
                      涨粉数 1 掉粉数 0
                    </div>
                  </div>
                </el-col>
                <el-col  :span="5">
                  <div class="文本框">
                    <div class="文本 居中">
                      昨日活跃粉丝数
                    </div>
                    <div class="文本-巨型 居中">
                      6666
                    </div>
                  </div>
                </el-col>
                <el-col :span="5">
                  <div class="文本框">
                    <div class="文本 居中">
                      昨日活跃粉丝占比
                    </div>
                    <div class="文本-巨型 居中">
                      75.9%
                    </div>
                  </div>
                </el-col>
                <el-col  :span="5">
                  <div class="文本框">
                    <div class="文本 居中">
                      昨日粉丝总数
                    </div>
                    <div class="文本-巨型 居中">
                      6666
                    </div>
                  </div>
                </el-col>
              </el-row>

              <!--选择天数-->
              <el-row>
                <el-col :span="12">
                  <div class="文本-大" style="margin-top: 10px; margin-bottom: 20px;">数据趋势</div>
                </el-col>
                <el-col :span="12" class="右侧">
                  <el-select v-model="defaultOption" placeholder="">
                    <el-option
                        v-for="item in options"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                    </el-option>
                  </el-select>
                </el-col>
              </el-row>

              <el-tabs type="border-card" v-model="activeName_3" @tab-click="handleClick" >
                <!--折线图-->
                <el-tab-pane label="折线图" name="1">
                  <div id="main" style="width: 1000px; height:400px;"></div>
                </el-tab-pane>
                <!--列表-->
                <el-tab-pane label="列表" name="2">
                  <el-table
                      :data="dataTable"
                      style="width: 100%">
                    <el-table-column
                        prop="time"
                        label="时间">
                    </el-table-column>
                    <el-table-column
                        prop="total"
                        label="总粉丝数"
                        width="100"
                        fixed="right"
                        align="center">
                    </el-table-column>
                    <el-table-column
                        prop="change"
                        label="粉丝变化数"
                        width="100"
                        fixed="right"
                        align="center">
                    </el-table-column>
                    <el-table-column
                        prop="up"
                        label="涨粉数"
                        width="100"
                        fixed="right"
                        align="center">
                    </el-table-column>
                    <el-table-column
                        prop="down"
                        label="掉粉数"
                        width="100"
                        fixed="right"
                        align="center">
                    </el-table-column>
                    <el-table-column
                        prop="active"
                        label="活跃粉丝数"
                        width="100"
                        fixed="right"
                        align="center">
                    </el-table-column>
                  </el-table>
                  <br/>
                  <el-pagination
                      background
                      layout="prev, pager, next"
                  >
                  </el-pagination>
                </el-tab-pane>
              </el-tabs>

              <el-row :gutter="16" type="flex" justify="center">
                <!--性别分布-->
                <el-col :span="12">
                  <div class="文本框-灰色">
                    <div class="文本-中">性别分布</div>
                    <div id="main2" style="width: 450px; height:300px; align-content: center"></div>
                  </div>
                </el-col>
                <!--年龄分布-->
                <el-col :span="12">
                  <div class="文本框-灰色">
                    <div class="文本-中">年龄分布</div>
                    <div id="main3" style="width: 450px; height:300px; align-content: center"></div>
                  </div>
                </el-col>
              </el-row>
              <!--地域分布-->
              <div class="文本框-灰色-无间距">
              </div>
            </el-tab-pane>
            <!--粉丝列表-->
            <el-tab-pane>
              <span slot="label" style="font-size: 18px">粉丝列表</span>
              <!--表格-->
              <el-table
                  :data="fans"
                  style="width: 100%"
                  :show-header="false">
                <el-table-column
                    label="用户"
                    width="50">
                  <template slot-scope="scope">
                    <el-avatar shape="square" :size="40" :src="scope.row.userAvatar"></el-avatar>
                  </template>
                </el-table-column>
                <el-table-column
                    prop="nickname">
                </el-table-column>
              </el-table>
              <br/>
              <!--分页-->
              <el-pagination
                  background
                  layout="prev, pager, next"
                  :total="total"
                  :current-page="current"
                  :page-size="pageSize"
                  @current-change="handleCurrentChange"
              >
              </el-pagination>
            </el-tab-pane>
          </el-tabs>
        </div>
      </el-col>
    </el-row>

    <!--取消关注对话框-->
    <el-dialog
        title="提示"
        :visible.sync="dialogVisible"
        width="30%"
        :before-close="handleClose">
      <span>您确定要取消关注？</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确定</el-button>
  </span>
    </el-dialog>
    <div class="页眉">
    </div>
  </div>
</template>

<style>
.deleteBorder .el-tabs__nav-wrap::after{
  height: 0;
}
/*去掉el-tab-pane切换时的蓝色下划线*/
.deleteBorder .el-tabs__active-bar{
  background: transparent;
}

 .el-tabs--border-card {
   box-shadow: none;
 }

</style>

<script>
import * as echarts from 'echarts';
export default {
  mounted() {
    //折线图
    var chartDom = document.getElementById('main');
    var myChart = echarts.init(chartDom);
    var option;

    option = {
      tooltip: {
        trigger: 'axis'
      },
      legend: {
        data: ['总粉丝数', '粉丝变化数', '涨粉数', '掉粉数', '活跃粉丝数']
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          name: '总粉丝数',
          type: 'line',
          stack: '1',
          data: [120, 132, 101, 134, 90, 230, 210]
        },
        {
          name: '粉丝变化数',
          type: 'line',
          stack: '2',
          data: [220, 182, 191, 234, 290, 330, 310]
        },
        {
          name: '涨粉数',
          type: 'line',
          stack: '3',
          data: [150, 232, 201, 154, 190, 330, 410]
        },
        {
          name: '掉粉数',
          type: 'line',
          stack: '4',
          data: [320, 332, 301, 334, 390, 330, 320]
        },
        {
          name: '活跃粉丝数',
          type: 'line',
          stack: '5',
          data: [820, 932, 901, 934, 1290, 1330, 1320]
        }
      ]
    };
    option && myChart.setOption(option);


    //性别分布
    var chartDom2 = document.getElementById('main2');
    var myChart2 = echarts.init(chartDom2);
    var option2;

    option2 = {
      tooltip: {
        trigger: 'item'
      },

      series: [
        {
          name: '访问来源',
          type: 'pie',
          radius: ['40%', '70%'],
          avoidLabelOverlap: false,
          data: [
            {value: 1048, name: '男性'},
            {value: 735, name: '女性'}
          ]
        }
      ]
    };

    option2 && myChart2.setOption(option2);

    var chartDom3 = document.getElementById('main3');
    var myChart3 = echarts.init(chartDom3);
    var option3;

    //年龄分布
    option3 = {
      xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
      },
      yAxis: {
        type: 'value'
      },
      series: [{
        data: [120, 200, 150, 80, 70, 110, 130],
        type: 'bar'
      }]
    };

    option3 && myChart3.setOption(option3);
  },
  data() {
    return {
      //选择天数
      options: [{
        value: '001',
        label: '7天'
      }, {
        value: '002',
        label: '30天'
      }],
      //默认选择天数
      defaultOption: '001',
      //两个标签页分别的默认选项
      activeName: '0',
      activeName_3: '1',
      circleUrl: "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
      squareUrl: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png",
      dialogVisible: false,
      //分页相关
      total: 100,
      pageSize: 10,
      current: 3,
      //是否已关注粉丝的数组，根据表格中的bool值选择显示对应的字符串
      followFlag:['关注','取消关注'],
      //粉丝列表
      fansTable: [{
        name: '麦克',
        rela: '嘿嘿',
        mark: '3',
        flag: '1',
        url: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"
      }, {
        name: '麦1克',
        rela: '嘿嘿',
        mark: '1',
        flag: '1',
        url: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"
      }, {
        name: '麦克',
        rela: '嘿嘿',
        mark: '4',
        flag: '1',
        url: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"
      }, {
        name: '麦克',
        rela: '嘿嘿',
        mark: '2',
        flag: '1',
        url: "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png"
      }],
      //数据趋势--列表
      dataTable: [{
        time: '2020/2/28',
        total: '1',
        change: '1',
        up: '1',
        down: '1',
        active: '1'
      },{
        time: '2020/2/28',
        total: '1',
        change: '1',
        up: '1',
        down: '1',
        active: '1'
      },
        {
          time: '2020/2/28',
          total: '1',
          change: '1',
          up: '1',
          down: '1',
          active: '1'
        }],
      queryByUserId:{
        idUser: window.sessionStorage.getItem("idUser")
      },
      fans: [],
    }
  },
  created() {
    this.getFansList()
  },
  methods: {
    async getFansList() {
      const {data: res} = await this.$http.get('http://39.102.77.65:8088/userfollow/fans', {
        params:this.queryByUserId
      })
      this.fans=res.fans
      console.log(res)
    },
    handleCurrentChange(newPage){
      console.log(newPage)
      this.current=newPage
    }
  }
};
</script>